package com.example.smart_city_0829.activity.sdkm;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.smart_city_0829.DeathData;
import com.example.smart_city_0829.R;
import com.example.smart_city_0829.base.BaseActivity;
import com.example.smart_city_0829.entity.sdkm.Activities;

public class ActivityDetailActivity extends BaseActivity {

    private ImageView im;
    private TextView name;
    private TextView content;
    private Button ok;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_detail2;
    }

    @Override
    protected void initView() {
        im = (ImageView) findViewById(R.id.im);
        name = (TextView) findViewById(R.id.name);
        content = (TextView) findViewById(R.id.content);
        ok = (Button) findViewById(R.id.ok);
    }

    @Override
    protected void initData() {
        String data = getIntent().getStringExtra("data");

        Activities activities = gson.fromJson(data, Activities.class);
        Glide.with(context)
                .load(activities.getPic())
                .into(im);
        name.setText(activities.getName());
        content.setText(activities.getContent());

    }

    @Override
    protected void initEvent() {
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int position = getIntent().getIntExtra("position", -1);
                Activities activities = DeathData.activities.get(position);
                if (activities.isIn()) {
                    showToastShort("您已经参加这次活动，无需重复参加！");
                } else {
                    showToastShort("感谢参加！");
                }
                activities.setIn(true);
            }
        });
    }

    @Override
    protected String getActionBarTitle() {
        return "";
    }
}